contentprovider: Add ref_storable_formats()
authorBenjamin Otte <otte@redhat.com>
Wed, 29 Nov 2017 09:07:52 +0000 (10:07 +0100)
committerBenjamin Otte <otte@redhat.com>
Sun, 3 Dec 2017 04:46:48 +0000 (05:46 +0100)
This is to be used for advocating to clipboard managers.

gdk/gdkcontentprovider.c
gdk/gdkcontentprovider.h

index 525a4eb12fb4c8e61c5ca14465cfea660cf6fa78..55aa3841c215a4354e3bdcc1a4d6050f40a15c2c 100644 (file)
@@ -34,6 +34,7 @@ struct _GdkContentProviderPrivate
 enum {
   PROP_0,
   PROP_FORMATS,
+  PROP_STORABLE_FORMATS,
   N_PROPERTIES
 };
 
@@ -65,6 +66,12 @@ gdk_content_provider_real_ref_formats (GdkContentProvider *provider)
   return gdk_content_formats_new (NULL, 0);
 }
 
+static GdkContentFormats *
+gdk_content_provider_real_ref_storable_formats (GdkContentProvider *provider)
+{
+  return gdk_content_provider_ref_formats (provider);
+}
+
 static void
 gdk_content_provider_real_write_mime_type_async (GdkContentProvider  *provider,
                                                  const char          *mime_type,
@@ -121,6 +128,10 @@ gdk_content_provider_get_property (GObject    *gobject,
       g_value_take_boxed (value, gdk_content_provider_ref_formats (provider));
       break;
 
+    case PROP_STORABLE_FORMATS:
+      g_value_take_boxed (value, gdk_content_provider_ref_storable_formats (provider));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
       break;
@@ -137,6 +148,7 @@ gdk_content_provider_class_init (GdkContentProviderClass *class)
   class->attach_clipboard = gdk_content_provider_real_attach_clipboard;
   class->detach_clipboard = gdk_content_provider_real_detach_clipboard;
   class->ref_formats = gdk_content_provider_real_ref_formats;
+  class->ref_storable_formats = gdk_content_provider_real_ref_storable_formats;
   class->write_mime_type_async = gdk_content_provider_real_write_mime_type_async;
   class->write_mime_type_finish = gdk_content_provider_real_write_mime_type_finish;
   class->get_value = gdk_content_provider_real_get_value;
@@ -157,6 +169,22 @@ gdk_content_provider_class_init (GdkContentProviderClass *class)
                         G_PARAM_STATIC_STRINGS |
                         G_PARAM_EXPLICIT_NOTIFY);
 
+  /**
+   * GdkContentProvider:storable-formats:
+   *
+   * The subset of formats that clipboard managers should store this provider's data in.
+   *
+   * Since: 3.94
+   */
+  properties[PROP_STORABLE_FORMATS] =
+    g_param_spec_boxed ("storable-formats",
+                        "Storable formats",
+                        "The formats that data should be stored in",
+                        GDK_TYPE_CONTENT_FORMATS,
+                        G_PARAM_READABLE |
+                        G_PARAM_STATIC_STRINGS |
+                        G_PARAM_EXPLICIT_NOTIFY);
+
   /**
    * GdkContentProvider:content-changed:
    *
@@ -196,6 +224,26 @@ gdk_content_provider_ref_formats (GdkContentProvider *provider)
   return GDK_CONTENT_PROVIDER_GET_CLASS (provider)->ref_formats (provider);
 }
 
+/**
+ * gdk_content_provider_ref_storable_formats:
+ * @provider: a #GdkContentProvider
+ *
+ * Gets the formats that the provider suggests other applications to store
+ * the data in.  
+ * An example of such an application would be a clipboard manager.
+ *
+ * This can be assumed to be a subset of gdk_content_provider_ref_formats().
+ *
+ * Returns: (transfer full): The storable formats of the provider
+ **/
+GdkContentFormats *
+gdk_content_provider_ref_storable_formats (GdkContentProvider *provider)
+{
+  g_return_val_if_fail (GDK_IS_CONTENT_PROVIDER (provider), NULL);
+
+  return GDK_CONTENT_PROVIDER_GET_CLASS (provider)->ref_storable_formats (provider);
+}
+
 void
 gdk_content_provider_content_changed (GdkContentProvider *provider)
 {
index 90b9eae88ba4783374b7a1482b299eb704f3c8a5..1ce1962397944af1266999bc711e4461bfda131e 100644 (file)
@@ -58,6 +58,7 @@ struct _GdkContentProviderClass
                                                                          GdkClipboard           *clipboard);
 
   GdkContentFormats *   (* ref_formats)                                 (GdkContentProvider     *provider);
+  GdkContentFormats *   (* ref_storable_formats)                        (GdkContentProvider     *provider);
   void                  (* write_mime_type_async)                       (GdkContentProvider     *provider,
                                                                          const char             *mime_type,
                                                                          GOutputStream          *stream,
@@ -90,6 +91,8 @@ GType                   gdk_content_provider_get_type                   (void) G
 
 GDK_AVAILABLE_IN_3_94
 GdkContentFormats *     gdk_content_provider_ref_formats                (GdkContentProvider     *provider);
+GDK_AVAILABLE_IN_3_94
+GdkContentFormats *     gdk_content_provider_ref_storable_formats       (GdkContentProvider     *provider);
 
 GDK_AVAILABLE_IN_3_94
 void                    gdk_content_provider_content_changed            (GdkContentProvider     *provider);